aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/groups/[groupId]/stats/totals-your-spending.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/groups/[groupId]/stats/totals-your-spending.tsx')
-rw-r--r--src/app/groups/[groupId]/stats/totals-your-spending.tsx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/app/groups/[groupId]/stats/totals-your-spending.tsx b/src/app/groups/[groupId]/stats/totals-your-spending.tsx
new file mode 100644
index 0000000..f621a41
--- /dev/null
+++ b/src/app/groups/[groupId]/stats/totals-your-spending.tsx
@@ -0,0 +1,30 @@
+'use client'
+import { getGroup, getGroupExpenses } from '@/lib/api'
+import { useActiveUser } from '@/lib/hooks'
+import { getTotalActiveUserPaidFor } from '@/lib/totals'
+import { formatCurrency } from '@/lib/utils'
+
+type Props = {
+ group: NonNullable<Awaited<ReturnType<typeof getGroup>>>
+ expenses: NonNullable<Awaited<ReturnType<typeof getGroupExpenses>>>
+}
+
+export function TotalsYourSpendings({ group, expenses }: Props) {
+ const activeUser = useActiveUser(group.id)
+
+ const totalYourSpendings =
+ activeUser === '' || activeUser === 'None'
+ ? 0
+ : getTotalActiveUserPaidFor(activeUser, expenses)
+ const currency = group.currency
+
+ return (
+ <div>
+ <div className="text-muted-foreground">Total you paid for</div>
+
+ <div className="text-lg">
+ {formatCurrency(currency, totalYourSpendings)}
+ </div>
+ </div>
+ )
+}